@extends('admin.admin')

@section('content')
        <!-- Content Header (Page header) -->
<section class="content-header">
    <h1>
        商品管理
        <small>活动专题</small>
        <small>专题分类</small>
        <small>活动商品</small>
    </h1>
    <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> 控制面板</a></li>
        <li ><a href="/admin/activity">活动专题</a></li>
        <li ><a href="/admin/activity_cat?id={{Request::get('activity_id')}}">专题分类</a></li>
        <li class="active"><a href="#">活动商品</a></li>
    </ol>
</section>

<!-- Main content -->
<section class="content">

    <div class="row">


        <div class="col-xs-12">
            {!! Form::model($activityGoods,array('route' => 'admin.activity_goods.sort','class'=>'form-horizontal')) !!}
            <div class="box box-primary">
                <div class="box-header">
                    <h3 class="box-title">活动商品列表</h3>
                    <div class="pull-right">
                        <a type="button" class="btn btn-block btn-success btn-xs" href="/admin/activity_cat?id={{$activity_id}}"><i class="icon  glyphicon glyphicon glyphicon-menu-left"></i> 返回专题列表</a>
                    </div>
                </div>
                <!-- /.box-header -->
                <div class="box-body table-responsive no-padding">
                    {!! Form::hidden('_method', 'POST') !!}

                    {!! Form::hidden('url',@$_SERVER["REQUEST_URI"]) !!}
                    <table class="table table-hover">
                        <tr>
                            <th style="width:50px;">排序</th>                            
                            <th style="width:50px;">ID</th>
                            <th >商品名称</th>
                            <th style="width: 150px;">操作</th>

                        </tr>
                        @foreach ($activityGoods as $item)
                        <tr>
                            <td>{!! Form::text('sort_order['.$item->id.']',$item->sort_order,['class'=>'input-mini','style'=>'text-align:center;width: 30px;height:30px;margin-bottom:0px;'])!!}</td>
                            <td>{{@$item->id}}</td>                            
                            <td>{{@$item->goods->goods_name}}</td>
                            <!-- <td>{{$item->sort_order}}</td> -->                       
                            
                            
                            <td>                               
                                <!-- <a href="{{Route('admin.activity_goods.edit',$item->id,$activity_cat_id)}}" type="button" class="btn  btn-default btn-xs"><i class="icon  glyphicon glyphicon-edit"></i> 修改</a> -->
                                <button type="button" class="btn  btn-danger btn-xs"  data-toggle="modal" data-target="#modal{{$item->id}}"><i class="icon  glyphicon glyphicon-remove"></i> 删除</button>

                                <div id="modal{{$item->id}}" class="modal fade">
                                    <div class="modal-dialog">
                                        <div class="modal-content">
                                            <div class="modal-header">
                                                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                                <h4 class="modal-title">删除警告:</h4>
                                            </div>
                                            <div class="modal-body">
                                                <p>确认要删除吗?</p>
                                            </div>
                                            <div class="modal-footer">

                                                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                                                <button itemid="{{$item->id}}" class="btn  btn-danger01" >删除</button>

                                                
                                            </div>
                                        </div><!-- /.modal-content -->
                                    </div><!-- /.modal-dialog -->
                                </div><!-- /.modal -->

                            </td>
                        </tr>
                        @endforeach

                    </table>
                </div>
                                                                
                <!-- /.box-body -->
                <div class="box-footer">
                    <!-- 分页 -->
                    <div class="pull-right no-margin-pager">
                        {!! $activityGoods->appends(['activity_id'=>$activity_id,'id'=>$activity_cat_id])->render() !!}
                    </div>
                    <button type="submit" class="btn btn-success"> 排序</button>

                </div>
                <!-- /.box-footer -->
            </div>
            {!! Form::close()  !!}

            <!-- /.box -->
        </div>
    </div>



</section>
<!-- /.content -->

<script>

        $('.btn-danger01').on('click',function(e){
            e.preventDefault();
            var id = $(this).attr("itemid");            
            if(!id) return false;
            $.ajax({
                url:'/admin/activity_goods/'+id+"?"+Math.random(),
                type:'delete',
                data:{id:id,'_token':'{{csrf_token()}}'},
                dataType:"json",
                success:function(result){                    

                    if(result.status){
                        $('#del_alert').modal();
                        $("#ok").hide();
                        $("#no").show();
                        $("#message_content").html(result.info);
                    }else{
                        window.location.reload();
                    }

                }

            });

        });      
        
        
    </script>
 
<script>
    $('.btn-danger').on('click',function(){
        console.log('11');
    });
</script>
@endsection